home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1996 April / EnigmA AMIGA RUN 06 (1996)(G.R. Edizioni)(IT)[!][issue 1996-04][Skylink CD V].iso / earcd / utilgfx / spp.lha / spp.doc < prev   
Text File  |  1996-03-02  |  7KB  |  221 lines

  1.  
  2.  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  3.  
  4.       S + P   I M A G E   C O M P R E S S I O N   P R O G R A M
  5.  
  6.  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  7.  
  8.                < ANSI C > version  1.09  -  02/01/96
  9.  
  10.  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  11.  
  12.    Copyright (c) 1996 by Amir Said & William A. Pearlman
  13.  
  14.  
  15.  
  16. DESCRIPTION
  17. ===========
  18.  
  19. The program "spp" contains an encoder and decoder for lossy and
  20. lossless compression of grayscale or color images. Its main purpose
  21. is the lossless compression of natural, scientific, database,
  22. multispectral, elevation maps, etc., images. In the lossless mode
  23. it has full verification of the image integrity (including the header
  24. and its comments, title, etc.).
  25.  
  26. It supports images originally scanned with up to 16 bits/pixel/color,
  27. accepts some well-known image header and formats, and up to 256 "color
  28. dimensions" (1 for greyscale, 3 for RGB, 4 for CMYK, n for multispectral). 
  29. The source code is available to those that need to compress images with
  30. special features and formats. It was written to be simple and fast, and
  31. not use any patented algorithm. Under such conditions it cannot represent
  32. the state-of-the-art for all cases, but it is quite good for regular use.
  33. (Please do not use it for comparisons!)
  34.  
  35. As an extra feature, the program allows some limited forms of lossy
  36. compression. It is quite efficient for the "near-lossless" compression
  37. of graylevel images, and can give users the opportunity to see how
  38. their images are affected by moderate lossy compression. It uses a
  39. wavelet-based compression method and the recovered lossy images
  40. tend to look quite good, with nearly uniform-distributed errors.
  41.  
  42. For those that are not coding specialists it should be stressed that
  43. higher compression ratios MUST yield large approximation errors,
  44. which are unevenly distributed throughout the image, and can be
  45. unacceptable for images that are meant to be processed (instead of
  46. just looked at). If for your images large error are acceptable, you
  47. may consider other compression programs.
  48.  
  49. In the lossy mode it compresses the color components separately. This
  50. is not the most efficient scheme, but it the only one that can be used
  51. when the color space is not known, and when the components may not
  52. represent true colors.
  53.  
  54.  
  55. USAGE
  56. =====
  57.  
  58. Only one program is used for coding and decoding, and the file name
  59. extension is used to identify the type of image. The usage to encode
  60. images with a known header is
  61.  
  62. > spp file_name.ext [lossy_compression_factor]
  63.  
  64. (Arguments between [ ] are optional.)
  65.  
  66. The presently accepted extension are
  67.  
  68.      .ras -> SUN rasterfile format, 8 and 24 bpp images
  69.      .pgm -> "portable graymap format" - grayscale raw images
  70.      .ppm -> "portable  pixmap format" - color raw images
  71.  
  72. The encoder changes the extension and writes to the compressed file
  73. "file_name.spc". The lossy compression factor is a number between
  74. 0 and 12, with 0 for lossless compression and 12 for maximum lossy
  75. compression. The default value is 0.
  76.  
  77. As a rule-of-thumb, for values smaller than 7 the lossy compression
  78. factor represents the expected maximum magnitude of the reconstruction
  79. error. 
  80.  
  81. To recover a compressed image use
  82.  
  83. > spp file_name.spc
  84.  
  85. If the original file exists in the same directory the decoder will
  86. ask if it can be overwritten.
  87.  
  88. The program can compress images without header if their name
  89. extension is ".raw". The usage is
  90.  
  91. > spp file_name.raw width [height] [bits/pixel] [lossy_factor]
  92.  
  93. Here the last parameters are optional, but they should be typed
  94. up to the parameter that is not meant to be the default. The
  95. parameter bits/pixel correspond to the original image (not the
  96. compressed).
  97.  
  98. The defaults are: 
  99.   height       = width
  100.   bits/pixel   = 8
  101.   lossy_factor = 0
  102.  
  103.  
  104. REMARKS
  105. =======
  106.  
  107. (1) The header is copied (byte-by-byte) to the compressed file,
  108. and then copied back to the recovered file. In the lossless mode
  109. 32 bits CRC error detection is used to assure the image integrity
  110. (including header).
  111.  
  112. (2) The program was not designed to code to rates near or below
  113. 0.5 bpp. So, it becomes less efficient for very smooth image or
  114. when the lossy compression factor is near its maximum.
  115.  
  116. (3) The memory usage is relatively small because only a "slice" of
  117. the image (with 32 pixels of height) is kept in memory at each time.
  118. If necessary, the memory utilization can be optimized by changing
  119. the following definition of type "Pic" in file "spp_code.h":
  120.  
  121.     typedef long Pic;
  122.  
  123. The required space is:
  124.  
  125.   original size    "Pic" size    type (depending on compiler)
  126.     <= 11 bpp        16 bits         short or int
  127.     >= 12 bpp        32 bits         long or int
  128.  
  129.  
  130. EXAMPLES
  131. ========
  132.  
  133. (1) To compress "lena" in Sun's rasterfile format just type
  134.  
  135. > spp lena.ras
  136.  
  137. and to recover
  138.  
  139. > spp lena.spc
  140.  
  141. (2) To compress "lena" 512x512, 8 bpp, in raw format
  142.  
  143. > spp lena.raw 512
  144.  
  145. or
  146.  
  147. > spp lena.raw 512 512 8 1 0
  148.  
  149. and to recover just type (note that the decoder recovers
  150. to the original format and extension)
  151.  
  152. > spp lena.spc
  153.  
  154. (3) Lossy compression of lena
  155.  
  156. > spp lena.ras 5
  157.  
  158. or
  159.  
  160. > spp lena.raw 512 512 8 1 5
  161.  
  162. Recovery in both cases
  163.  
  164. > spp lena.spc
  165.  
  166.  
  167. COMPILATION
  168. ===========
  169.  
  170. For UNIX compilation with GNU's gcc compiler the  program comes with
  171. a script file called "compile". So, just type "compile" at the prompt
  172. to execute
  173.  
  174. gcc -O2 -o spp spp_main.c spp_proc.c
  175.  
  176. The option O2 is used to call the optimizing compiler.
  177.  
  178.  
  179. ALGORITHM
  180. =========
  181.  
  182. The compression algorithm uses the S+P transform (Said &  Pearlman,
  183. SPIE VCIP Symposium, Cambridge, MA, Nov. 1993) and Huffman coding
  184. working on groups of 2x2 pixels (to allow coding rates below 1 bpp).
  185.  
  186.  
  187. CONTACT
  188. =======
  189.  
  190. Amir Said: amir@densis.fee.unicamp.br
  191. DENSIS - Faculty of Electrical Engineering
  192. University of Campinas (UNICAMP)
  193. Campinas, SP 13081, Brazil
  194.  
  195. William A. Pearlman - pearlman@ecse.rpi.edu
  196. Dept. of Electrical, Computer, and Systems Engineering
  197. Rensselaer Polytechnic Institute
  198. Troy, NY 12180, USA
  199.  
  200.  
  201. CONTRIBUTIONS
  202. =============
  203.  
  204. Suggestions for program modifications are welcome! Let us know
  205. if you improved the program, added (or want to add) a new header
  206. format, etc.
  207.  
  208.  
  209. COPYRIGHT
  210. =========
  211.  
  212. This program is Copyright (c) by Amir Said & William A. Pearlman.
  213. It can be freely copied and used for personal use, but it
  214. should not be copied, redistributed, edited, sold for profit, or
  215. incorporated in commercial programs without the written permission
  216. of the copyright holders. This program is provided as is, without
  217. any express or implied warranty, without even the warranty of
  218. fitness for a particular purpose.
  219.  
  220.  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  221.